<template>
  <!-- 1.3 辅助监控 -->
  <!-- 首页：全站总览（Overview） -->
  <div class="homepage">
    <div class="left">
      <template v-if="activeRouter===1">
        <HomeLeft />
      </template>
      <template v-if="activeRouter===2">
        <SecondLevel />
      </template>
    </div>
    <div class="right">
      <router-view class="homepage-view"></router-view>
    </div>
  </div>
</template>

<script lang="ts">
import HomeLeft from "./components/HomeLeft.vue";
import SecondLevel from "./components/SecondLevel.vue";
import { Component, Vue, Watch } from "vue-property-decorator";
import { publicAPIModule } from "@/store/modules/public";
import { OnlineMonitorModule } from "@/store/modules/OnlineMonitor";
@Component({
  components: { HomeLeft, SecondLevel },
})
export default class extends Vue {
  public activeRouter = 1;
  @Watch("$route", { immediate: true, deep: true })
  public routechange(to: any, from: any) {
    // console.log(to);
    if (to.meta.name === "Home") {
      this.activeRouter = 1;
    } else if (to.meta.name === "secondLevel") {
      this.activeRouter = 2;
    }
  }
  created() {
    publicAPIModule.queryHasDataStations("OL");
  }
  mounted() {
    //  publicAPIModule.queryHasDataStations('OL');
    OnlineMonitorModule.setStationName(this.$route.query);

    publicAPIModule.setstationTreeList({ deviceBoard: 3 }); //公共方法-变电站树图
    publicAPIModule.queryStations(); //下拉框变电站
  }
}
</script>
<style lang="scss" scoped>
.homepage {
  width: 100%;
  height: 100%;
  display: flex;
  box-sizing: border-box;
  padding: 0.88rem 0.24rem 0.24rem 0.24rem;
  .right {
    width: 100%;
    height: 100%;
    .homepage-view {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
